package com.qianxun.module.datasource1.develop.rest;


import com.qianxun.module.datasource1.admin.service.SysDataModifyLockService;
import com.qianxun.module.datasource1.develop.service.SysFunctionRoleRelationService;
import com.qianxun.module.datasource1.develop.util.SysFunctionRoleUtil;
import com.qianxun.module.base.constant.Result;
import com.qianxun.module.base.bo.ValidGroup;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;

/**
* com.zch.admin.base.entity.SysAdminFunctionRoleRelation模型http接口处理
*
* @author: admin
* @date: 2019-11-27
* @version: 1.0.0
*/
@Validated(value = {ValidGroup.All.class})
@RestController
@RequestMapping(value="/develop/functionRoleRelation" ,produces = {MediaType.APPLICATION_JSON_UTF8_VALUE})
public class SysFunctionRoleRelationRestController {

    @Resource
    private SysFunctionRoleRelationService baseService;
    @Resource
    private SysDataModifyLockService sysDataModifyLockService;

    @RequestMapping(value = {"/setAuthority/{functionRoleId}"})
    public Result setAuthority(@PathVariable(value = "functionRoleId")Integer functionRoleId ,@RequestParam(value = "functionIds") Integer[] functionIds ){
        sysDataModifyLockService.checkLocked(SysFunctionRoleUtil.dataLockKey(functionRoleId));

        baseService.setAuthority(functionRoleId ,functionIds);
        return Result.success();
    }
}
